package function;

import java.util.ArrayList;

public class Sin extends Function {
	private Function sinFunction;

	public Sin(Function f) {
		sinFunction = f;
	}

	public Function getSinFunction() {
		return sinFunction;
	}

	public void setSinFunction(Function sinFunction) {
		this.sinFunction = sinFunction;
	}

	public double evaluate(double x) {
		return Math.sin(sinFunction.evaluate(x));
	}

	public Function differentiate() {
		ArrayList<Function> result = new ArrayList<Function>();
		result.add(sinFunction.differentiate());
		result.add(new Cos(sinFunction));
		return new Multiply(result);
	}

	public String toString() {
		return "sin(" + sinFunction.toString() + ")";
	}

}
